package com.mall.service.order.controller;

import com.mall.commons.common.CommonResult;
import com.mall.model.domain.OmsOrderReturnReason;
import com.mall.model.dto.ReasonPageDto;
import com.mall.model.vo.PageResult;
import com.mall.service.order.service.OmsOrderReturnReasonService;
import org.checkerframework.checker.units.qual.C;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/returnReason")
public class OmsOrderReturnReasonController {
    @Autowired
    private OmsOrderReturnReasonService os;
//添加退回原因
    @PostMapping("/create")
    public CommonResult save(@RequestBody OmsOrderReturnReason omsOrderReturnReason) {
        os.save(omsOrderReturnReason);
        return CommonResult.success("添加成功");
    }
//批量删除退货原因
    @PostMapping("/delete")
    public CommonResult delete(@RequestParam List<Integer>ids){
        String delete = os.delete(ids);
        return CommonResult.success(delete);
    }
    //分页查询退货原因
    @GetMapping("/list")
    public CommonResult list(Integer pageNum, Integer pageSize){
        PageResult list = os.list(pageNum, pageSize);
        return CommonResult.success(list);
    }
//修改退货原因和状态
    @PostMapping("/update/status")
    public CommonResult status(@RequestParam List<Integer>ids,Integer status){
        os.status(ids,status);
        return CommonResult.success("修改成功");
    }

    //修改退货原因
    @PostMapping("/update/{id}")
    public CommonResult update(@PathVariable Integer id,@RequestBody OmsOrderReturnReason reasonPageDto){
      os.update(id, reasonPageDto);
        return CommonResult.success("修改成功");
    }
    //获取单个退货原因详情信息
    @GetMapping("{id}")
        public CommonResult select(@PathVariable Integer id){
     OmsOrderReturnReason o= os.select(id);
        return CommonResult.success(o);
    }
    }
